package com.ruoyi.base.service.impl;

import java.util.List;

import cn.hutool.core.util.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.base.mapper.MPerformanceMapper;
import com.ruoyi.base.domain.MPerformance;
import com.ruoyi.base.service.IMPerformanceService;

/**
 * 员工绩效Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-08-09
 */
@Service
public class MPerformanceServiceImpl implements IMPerformanceService 
{
    @Autowired
    private MPerformanceMapper mPerformanceMapper;

    /**
     * 查询员工绩效
     * 
     * @param id 员工绩效主键
     * @return 员工绩效
     */
    @Override
    public MPerformance selectMPerformanceById(Long id)
    {
        return mPerformanceMapper.selectMPerformanceById(id);
    }

    /**
     * 查询员工绩效列表
     * 
     * @param mPerformance 员工绩效
     * @return 员工绩效
     */
    @Override
    public List<MPerformance> selectMPerformanceList(MPerformance mPerformance)
    {
        return mPerformanceMapper.selectMPerformanceList(mPerformance);
    }

    /**
     * 新增员工绩效
     * 
     * @param mPerformance 员工绩效
     * @return 结果
     */
    @Override
    public int insertMPerformance(MPerformance mPerformance)
    {
        //设置签订年月
        mPerformance.setSignYearmonth(mPerformance.getSignTime());

        //设置合同号
        Long sid = IdUtil.createSnowflake(1, 1).nextId();
        String sids=sid.toString().substring(sid.toString().length() - 16);
        mPerformance.setContractNum(sids);

        //设置员工名称
        mPerformance.setsName(mPerformanceMapper.selectName(mPerformance.getsId()));
        return mPerformanceMapper.insertMPerformance(mPerformance);
    }

    /**
     * 修改员工绩效
     * 
     * @param mPerformance 员工绩效
     * @return 结果
     */
    @Override
    public int updateMPerformance(MPerformance mPerformance)
    {
        return mPerformanceMapper.updateMPerformance(mPerformance);
    }

    /**
     * 批量删除员工绩效
     * 
     * @param ids 需要删除的员工绩效主键
     * @return 结果
     */
    @Override
    public int deleteMPerformanceByIds(Long[] ids)
    {
        return mPerformanceMapper.deleteMPerformanceByIds(ids);
    }

    /**
     * 删除员工绩效信息
     * 
     * @param id 员工绩效主键
     * @return 结果
     */
    @Override
    public int deleteMPerformanceById(Long id)
    {
        return mPerformanceMapper.deleteMPerformanceById(id);
    }
}
